|
class Length |
|
Parent: Object |
|
|
| |
|
Sample Code:lengthtests.rb |
|
Because length units are used so often in SketchUp, a special class has been added to make it easier to work with length values.
The Length class is derived from the Float class. You can use a Length object any place that you would use a Float.
Internally, all lengths in SketchUp are stored in inches. The Length class stores values in inches
A number of methods have been added to the Ruby Numeric class to do units conversions.|
Instance Methods |
|
< |
|
The < method is used to see if one length is less than another length. |
|
Syntax: |
|
status = length1 < length2 |
|
Arguments: |
|
length1 - a length value length2 - a length value |
|
Return Value: |
|
status - true if length1 is < length2; false if length1 is not < length2 |
|
Comments: |
|
For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 < l2 should return false. |
|
Example: |
|
length1 = 11 |
|
<= |
|
The <= method is used to see if one length is less than or equal to another length. |
|
Syntax: |
|
status = length1 <= length2 |
|
Arguments: |
|
length1 - a length value length2 - a length value |
|
Return Value: |
|
status - true if length1 is <= length2; false if length1 is not <= length2 |
|
Comments: |
|
For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 <= l2 should return true. |
|
Example: |
|
length1 = 11 |
|
<=> |
|
The <=> method is used to see if one length is less than equal or greater than another length. |
|
Syntax: |
|
status = length1 <=> length2 |
|
Arguments: |
|
length1 - a length value length2 - a length value |
|
Return Value: |
|
status - |
|
Comments: |
|
|
|
Example: |
|
length1 = 11 |
|
== |
|
The == method is used to see if one length is equal to another length. |
|
Syntax: |
|
status = length1 == length2 |
|
Arguments: |
|
length1 - a length value length2 - a length value |
|
Return Value: |
|
status - true if length1 is == length2; false if length1 is not == length2 |
|
Comments: |
|
|
|
Example: |
|
|
|
> |
|
The > method is used to see if one length is greater than another length. |
|
Syntax: |
|
status = length1 > length2 |
|
Arguments: |
|
length1 - a length value length2 - a length value |
|
Return Value: |
|
status - true if length1 is > length2; false if length1 is not > length2 |
|
Comments: |
|
For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 > l2 should return false. |
|
Example: |
|
length1 = 11 |
|
>= |
|
The >= method is used to see if one length is greater than or equal to another length. |
|
Syntax: |
|
status = length1 < length2 |
|
Arguments: |
|
length1 - a length value length2 - a length value |
|
Return Value: |
|
status - true if length1 is >= length2; false if length1 is not >= length2 |
|
Comments: |
|
For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 >= l2 should return true. Also L1 <= l2 would return true. |
|
Example: |
|
length1 = 11 |
|
inspect |
|
The inspect method is used to retrieve an unformatted string for the length. |
|
Syntax: |
|
length = length.inspect |
|
Arguments: |
|
|
|
Return Value: |
|
length - an unformatted length string |
|
Comments: |
|
|
|
Example: |
|
depth = 100 |
|
to_f |
|
The to_f method is used to convert a length to a normal float. |
|
Syntax: |
|
value = length.to_f |
|
Arguments: |
|
|
|
Return Value: |
|
value - the float length value |
|
Comments: |
|
|
|
Example: |
|
length = entities.length |
|
to_s |
|
The to_f method is used to convert a length to a string using current units. |
|
Syntax: |
|
length = length.to_s |
|
Arguments: |
|
|
|
Return Value: |
|
length - a length string |
|
Comments: |
|
|
|
Example: |
|
length = entities.length |